1
|
|
|
Amarkal.settings.sections = { |
|
|
|
|
2
|
|
|
$links: null, |
3
|
|
|
$loader: null, |
4
|
|
|
data: null, |
5
|
|
|
activeSection: null, |
6
|
|
|
prevSection: null, |
7
|
|
|
init: function() { |
8
|
|
|
this.data = JSON.parse($('#sections-config').text()); |
9
|
|
|
this.$links = $('.amarkal-settings-sections li'); |
10
|
|
|
this.$loader = $('#amarkal-settings-loader'); |
11
|
|
|
|
12
|
|
|
this.initSections(); |
13
|
|
|
}, |
14
|
|
|
initSections: function() { |
15
|
|
|
if(typeof this.data === 'object' && Object.keys(this.data).length > 0) { |
16
|
|
|
var _this = this; |
17
|
|
|
this.$links.on('click', function(){ |
18
|
|
|
_this.activate($(this).attr('data-slug')); |
19
|
|
|
}); |
20
|
|
|
this.activateInitialSection(); |
21
|
|
|
this.$loader.hide(); |
22
|
|
|
} |
23
|
|
|
else { |
24
|
|
|
Amarkal.settings.fields.showAll(); |
|
|
|
|
25
|
|
|
} |
26
|
|
|
}, |
27
|
|
|
activateInitialSection: function() { |
28
|
|
|
if('' !== window.location.hash) { |
29
|
|
|
this.activate(window.location.hash.substring(1)); |
30
|
|
|
} |
31
|
|
|
else { |
32
|
|
|
this.activate($(this.$links[0]).attr('data-slug')); |
33
|
|
|
} |
34
|
|
|
}, |
35
|
|
|
activate: function(sectionSlug) { |
36
|
|
|
if(this.activeSection === sectionSlug) { |
37
|
|
|
return; |
38
|
|
|
} |
39
|
|
|
if(this.activeSection !== null) { |
40
|
|
|
this.prevSection = this.activeSection; |
41
|
|
|
} |
42
|
|
|
this.activeSection = sectionSlug; |
43
|
|
|
|
44
|
|
|
this.$links |
45
|
|
|
.removeClass('active') |
46
|
|
|
.filter('[data-slug="'+sectionSlug+'"]') |
47
|
|
|
.addClass('active'); |
48
|
|
|
|
49
|
|
|
Amarkal.settings.header.setSectionTitle(this.getTitle(sectionSlug)); |
|
|
|
|
50
|
|
|
Amarkal.settings.header.setSectionSubtitle(this.getSubtitle(sectionSlug)); |
51
|
|
|
Amarkal.settings.fields.showBySection(sectionSlug); |
52
|
|
|
|
53
|
|
|
window.location = '#'+sectionSlug; |
54
|
|
|
}, |
55
|
|
|
deactivate: function() { |
56
|
|
|
var sectionSlug = this.activeSection; |
|
|
|
|
57
|
|
|
this.$links.removeClass('active'); |
58
|
|
|
Amarkal.settings.fields.hideAll(); |
|
|
|
|
59
|
|
|
this.activeSection = null; |
60
|
|
|
}, |
61
|
|
|
flag: function(type, slug) { |
62
|
|
|
this.$links.filter('[data-slug="'+slug+'"]').addClass('flag-'+type); |
63
|
|
|
}, |
64
|
|
|
unflagAll: function() { |
65
|
|
|
this.$links.removeClass('flag-error flag-notice'); |
66
|
|
|
}, |
67
|
|
|
getTitle: function(slug) { |
68
|
|
|
return this.data[slug].title; |
69
|
|
|
}, |
70
|
|
|
getSubtitle: function(slug) { |
71
|
|
|
return this.data[slug].subtitle; |
72
|
|
|
} |
73
|
|
|
}; |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.